//
//  ChoiceEntAddressBookContactCell.m
//  mcrmSAAS
//
//  Created by wjxfhxy on 14-9-22.
//  Copyright (c) 2014年 GuangZhouXuanWu. All rights reserved.
//

#import "ChoiceEntAddressBookContactCell.h"

@interface ChoiceEntAddressBookContactCell ()
{
    HeadImageView *_headImageView;
}
@end

@implementation ChoiceEntAddressBookContactCell

-(id)initWithReuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithReuseIdentifier:reuseIdentifier];
    
    _selector = [[XUISelector alloc] initWithFrame:CGRectMake(10,( 60 -30 )/2, 30, 30) title:nil headImage:[UIImage imageNamed:@"choicecontact_uncheck.png"] highlightedImage:[UIImage imageNamed:@"choicecontact_check.png"]];
    _selector.userInteractionEnabled = NO;
    [self.contentView addSubview:_selector];
    
    _headImageView = [[HeadImageView alloc]initWithFrame:CGRectMake(0,0, 36, 36)];
    [self.contentView addSubview:_headImageView];
    
    CGSize s = [NSString charSizeWithSystemFontSize:16];
    _name = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, s.width, s.height)];
    _name.backgroundColor = [UIColor clearColor];
    _name.font = [UIFont systemFontOfSize:16];
    [self.contentView addSubview:_name];
    
    s = [NSString charSizeWithSystemFontSize:14];
    _department = [[UILabel alloc]initWithFrame:CGRectMake(0, 0, s.width*15, s.height)];
    _department.backgroundColor = [UIColor clearColor];
    _department.font = [UIFont systemFontOfSize:14];
    _department.textColor = [UIColor colorWithHex:mcrmSAASUISkinColorTextStyle9b9b9bColor];
    [self.contentView addSubview:_department];
    
    return self;
}

-(void)layoutSubviews
{
    [super layoutSubviews];
    
    CGFloat l = _selector.right;
    if(_selector.hidden == YES)
        l = 0;
    
    _headImageView.origin = CGPointMake(l + 10, 0);
    _headImageView.centerY = self.contentView.height/2;
    
    _name.origin = CGPointMake(_headImageView.right + 10, 10);
    //10为字母导航条宽度，大约估算
    _name.width = self.contentView.width - _headImageView.right - 10 - 10;
    _department.origin = CGPointMake(_headImageView.right + 10, _name.bottom + 3);
}

+(CGFloat)caleHeight
{
    return 60;
}

-(void)setHeadImage:(UIImage *)headImage
{
    _headImageView.headImage = headImage;
}

-(void)setHiddenSelector:(BOOL)hiddenSelector
{
    _selector.hidden = hiddenSelector;
}

@end
